<template>
  <div class="home-singerDetails">
    <div id="tit">
      <h3>歌手介绍</h3>
    </div>
    <div class="wrapper" ref="wrapper">
      <ul class="content" ref="content">
        <li v-for="(item, index) in listData" :key="index" @click="selectItem(item)">
          <div class="cover">
            <van-image :src="item.img1v1Url"></van-image>
            <!-- <span>{{ item.playCount }}</span> -->
          </div>
          <span>{{ item.name }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import { betterScrollHorizontal } from "@/common/betterScroll";
export default {
  data() {
    return {
      listData: [],
    };
  },
  created() {
    this.getSongListData();
  },
  methods: {
    getSongListData() {
      this.$request("get", "/artist/list").then((res) => {
        console.log(res);
        if (res.code == 200) {
          let { artists } = res;
          this.listData = artists;
        }
        betterScrollHorizontal(
          this,
          this.$refs.wrapper,
          this.$refs.content,
          this.listData.length,
          10
        ); //调用横向滚动的方法
      });
    },
    selectItem(item) {
      const id = item.id;
      // this.$store.commit("saveSinger", item);
      this.$store.dispatch("saveSinger", item);
      this.$router.push(`/singerDetails/${id}`);
    },
  },
};
</script>
<style scoped>
h2 {
  margin-left: 0.2rem;
}

.wrapper {
  width: 100%;
  overflow: hidden;
}

ul.content li {
  display: inline-block;
  width: 10rem;
  vertical-align: top;
}

ul.content li * {
  margin: 0.1rem;
}

ul.content li>span {
  display: inline-block;
  width: 100%;
  font-size: 0.8rem;
  color: #54493b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cover>span {
  position: absolute;
  right: 0.2rem;
  bottom: 0.3rem;
  background-color: rgba(255, 255, 255, 0.4);
  color: white;
  font-size: 14px;
  border-radius: 1rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  box-sizing: border-box;

  display: inline-block;
}

.cover {
  position: relative;
}
</style>